<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>0</h1>
<script>
   setInterval(f,1000);
  let count=0;
  function f() {
    count++
    let h = document.querySelector("h1")
    h.innerText = count;

  }
   let inter = setInterval(function () {
    console.log(count)
     if(count==5){
       clearInterval(inter)
     }
  },1000)

  setTimeout(function () {
    console.log("时间到")
  },3000)
</script>
</body>
</html>